<?php
namespace app\api\controller;

use app\common\controller\Common;
use app\common\exception\ParameterException;
use think\Request;
use app\common\logic\Collection as CollectionLogic;
use think\Loader;


/**
 * @title 收藏模块接口
 * @description 接口说明
 * @group 接口分组
 *
 */

class Collection extends Common
{
    /**
     * @title 获取某商店的收藏列表
     * @description 接口说明
     * @author WCJ
     * @url /api/collection/collection_list
     * @method POST
     * @param name:shopid type:int require:0 default:1 other: desc:店家id
     * @param name:start type:int require:0 default:1 other: desc:开始数
     * @param name:num type:int require:0 default:1 other: desc:数量
     *
     * @return id: 分类ID
     * @return name: 分类名称
     * @return pictureid: 分类图标
     *
     */
    public function collection_list(Request $request)
    {
          $shopid = $request->post("shopid");
          session("collection",null);
          $start = $request->post('start') ? $request->post('start') : 1;
          $num = $request->post('num') ? $request->post('num') : 20;
          $validate = Loader::validate("Common");
          if (!$validate->scene("common")->check(['id' => $shopid])) {
              throw new ParameterException(['code' => 201,'errorCode' => 400, 'msg' => $validate->getError()]);
            die();
          }
          $collectionlogic=new CollectionLogic();
          $shop_array=$collectionlogic->getCollectionListByShopid($shopid,$start,$num);
          $datas= ["code"=>200,"msg"=>"成功","data"=>$shop_array];
          return $datas;
    }



}